package com.zhuangjie.coupon.vo;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * 使用的优惠券核心信息容器
 *
 * @author zhuangjie
 * @date 2024/03/30
 */
@Getter
@Setter
public class UseCouponCoreInfoContainer {
    /**
     * 使用的店铺优惠券
     */
    private List<CouponCoreInfoAndPreferentialAmount> useShopCouponPreferentialInfoList;
    /**
     * 使用的平台优惠券
     */
    private List<CouponCoreInfoAndPreferentialAmount> usePlatformCouponPreferentialInfoList;

    public boolean isAllEmpty() {
        return ( useShopCouponPreferentialInfoList == null || useShopCouponPreferentialInfoList.isEmpty()) && (usePlatformCouponPreferentialInfoList == null || usePlatformCouponPreferentialInfoList.isEmpty());
    }

    /**
     * 将所有便券融合为一个List
     * @return
     */
    public List<CouponCoreInfoAndPreferentialAmount> fuse() {
        // 将usedShopCouponList与usedPlatformCouponList合并为一个List
        List<CouponCoreInfoAndPreferentialAmount> result = new ArrayList<>();
        if (useShopCouponPreferentialInfoList != null && !useShopCouponPreferentialInfoList.isEmpty()) {
            result.addAll(useShopCouponPreferentialInfoList);
        }
        if (usePlatformCouponPreferentialInfoList != null && !usePlatformCouponPreferentialInfoList.isEmpty()) {
            result.addAll(usePlatformCouponPreferentialInfoList);
        }
        return result;
    }

}
